<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/page/common/commonConfig.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
    <base href="<%=basePath%>">
    <title>查询游离用户</title>
    <script src="<%=basePath%>component/layout.js"></script>
    <script src="<%=basePath%>component/toolbar.js"></script>
	<script src="<%=basePath%>component/grid.js"></script>
	<script type="text/javascript" src="<%=basePath%>dwrsystem/engine.js"></script>
	<script type="text/javascript" src="<%=basePath%>dwrsystem/interface/userService.js"></script>
	
	<script type="text/javascript">
	var mygrid;
	var dhxLayout = createLayoutNormal('1C',false,true);
	
	var dhxGrid = {
		initDataTable : function () {
		    mygrid.setHeader("序号,登录账号,登录姓名,备注");
		    mygrid.setInitWidths("50,150,150,*");
		    mygrid.setColAlign("right,left,left,left");
		    mygrid.setColSorting("int,str,str,str");
		    mygrid.setColTypes("ro,ro,ro,ro");
		    mygrid.attachEvent("onRowSelect", this.reloadParentSystemAndBusinessGrid);
		    mygrid.attachEvent("onRowDblClicked", this.showInfos);
		    mygrid.attachEvent("onEnter", this.showInfos);
		    mygrid.init();
		    setSkin(mygrid);
		    mygrid.loadXML('<%=basePath%>system-user/UserAction!userGridDetach.action');
		},
		deleteInfo : function (){
			if(mygrid.getSelectedId()){
				layoutProgressOn(dhxLayout);
				userService.deleteTUserAll(mygrid.getSelectedId(),function(data){
					if(data == true){
						var lastrowIndex = mygrid.getRowIndex(mygrid.getSelectedId())-1;
						mygrid.deleteSelectedRows();
						mygrid.selectRow(lastrowIndex);
						
						//修改前面的序号
						for(var i=(lastrowIndex+1) ;i<(mygrid.getRowsNum());i++){
							mygrid.cells(mygrid.getRowId(''+i),0).setValue(i+1);
						}
						layoutProgressOff(dhxLayout);
						parent.parent.notifyCreater('操作成功');
					}else{
						parent.parent.notifyWarn('删除用户异常');
					}
				});
			}
			else parent.parent.notifyWarn('请选择删除项');
		},
		addToUnit : function (){
			var rowId = mygrid.getSelectedId();
			if(rowId){
				queryUnits(rowId);
			}else{
				parent.parent.notifyWarn('请选择操作项');
			}
		},
		reloadParentSystemAndBusinessGrid : function (){
			parent.reloadSystemAndBusinessGrid(mygrid.getSelectedId());
		},
		showInfos : function (){
			parent.createNoUnitUsersTabbar(mygrid.getSelectedId());
		}
	};

	function queryUnits(userId){
		parent.openUnits(userId);
	}

	function configLayout(){
		var a = dhxLayout.cells('a');
		a.hideHeader();
		a.setText('主页面');
		a.fixSize(true, true);
		mygrid = createGridFromLayoutCell(a);
		if(power.getPower() != '' && (power.getPowerInsert() || power.getPowerDelete()))
			createToolbarFromDHXLayoutCell(a,function(toolbar){
			    toolbar.addText("info", 1, "操作:");
			    toolbar.addSeparator("sep1", 2);
			    if(power.getPowerInsert())
			    	toolbar.addButton("add", 3, "加入", "new.gif", "new_dis.gif");
			    if(power.getPowerDelete())
			    	toolbar.addButton("delete", 4, "删除", "cut.gif", "cut_dis.gif");
			    toolbar.attachEvent("onClick", function(id) {
			    	if(id == 'add'){
			    		dhxGrid.addToUnit();
			    	}
			    	if(id == 'delete'){
			    		dhxGrid.deleteInfo();
			    	}
			    });
			});
	}
	
	$(function (){
		configLayout();
	 	dhxGrid.initDataTable();
	});
	</script>
</head>
  
<body>
</body>

</html>


